﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AvalonDock;
using System.Windows.Input;

namespace AWZhome.NQ.CommonServices
{
	/// <summary>
	/// Internal extension of AvalonDock's DocumentContent class, that is used by ViewManagerService
	/// in place of the original.
	/// </summary>
	internal class CSDocumentContent : DocumentContent
	{
		private ViewManagerService _viewManager;

		public CSDocumentContent(ViewManagerService viewManager)
		{
			_viewManager = viewManager;
		}

		public IView View
		{
			get;
			set;
		}

		//public override void OnApplyTemplate()
		//{
			// AvalonDock sets up the InputBinding for the middle-click here.
			// We try to avoid this by overriding this method.
		//}

		public override bool Close()
		{
			bool closeResult = base.Close();

			if (closeResult)
			{
				// Notify ViewManager about closing
				if (_viewManager != null)
				{
					_viewManager.OnViewContentClosed(this);
				}
			}

			return closeResult;
		}
	}
}
